function alertWin(title, msg, w, h){
var titleheight = "22px"; //提示窗口标题高度
var bordercolor = "#666699"; //提示窗口的边框颜色
var titlecolor = "#FFFFFF"; //提示窗口的标题颜色
var titlebgcolor = "#666699";
var bgcolor = "#FFFFFF";
var iWidth = document.documentElement.clientWidth;
var iHeight = document.documentElement.clientHeight;
var bgObj = document.createElement("div");
bgObj.id = "BgDiv";
bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=80);opacity:0.3;background-color:#000000;z-index:100;";
document.body.appendChild(bgObj);
var msgObj=document.createElement("div");
msgObj.id = "MsgDiv";
msgObj.style.cssText = "position:absolute;font:11px '宋体';top:"+(iHeight-h)/2+"px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:22px;z-index:102;";
document.body.appendChild(msgObj);
var table = document.createElement("table");
msgObj.appendChild(table);
table.style.cssText = "margin:0px;border:0px;padding:0px;";
table.cellSpacing = 0;
var tr = table.insertRow(-1);
var titleBar = tr.insertCell(-1);
titleBar.style.cssText = "width:100%;height:"+titleheight+"px;text-align:left;padding:3px;margin:0px;font:bold 13px '宋体';color:"+titlecolor+";border:1px solid " + bordercolor + ";cursor:move;background-color:" + titlebgcolor+";";
titleBar.style.paddingLeft = "10px";
titleBar.innerHTML = title;
var mask = document.createElement("iframe");
mask.src="javascript:false";
mask.scrolling="no";
mask.frameborder="0";
mask.style.cssText = "position:absolute;z-index:"+msgObj.style.zIndex-1+";top:"+msgObj.style.top+";left:"+msgObj.style.left+";width:"+msgObj.style.width+";height:"+msgObj.style.height+";";
mask.style.position="absolute";
document.body.appendChild(mask);
var moveX = 0;
var moveY = 0;
var moveTop = 0;
var moveLeft = 0;
var moveable = false;
addEvent(msgObj, "mousedown", mousedown);
addEvent(msgObj, "mouseup", mouseup);
addEvent(msgObj, "selectstart", function() {return false;});
addEvent(msgObj, "mousemove", mousemove);
var resizeEvent;
function mousedown() {
moveable = true;
resizeEvent=window.onresize;
window.onresize = function() {
bgObj.style.width = document.documentElement.clientWidth + "px";
bgObj.style.height = documes3Qnt.documentElement.clientHeight + "px";
}
if (getBrowser()=="IE") msgObj.setCapture();
var evt = getEvent();
moveX = evt.clientX;
moveY = evt.clientY;
moveTop = parseInt(msgObj.style.top);
moveLeft = parseInt(msgObj.style.left);
}
function mousemove() {
if (moveable) {
var evt = getEvent();
var x = moveLeft + evt.clientX - moveX;
var y = moveTop + evt.clientY - moveY;
msgObj.style.left = x + "px";
msgObj.style.top = y + "px";
mask.style.left = msgObj.style.left;
mask.style.top = msgObj.style.top;
}
}
function mouseup() {
if (moveable) {
moveX = 0;
moveY = 0;
moveTop = 0;
moveLeft = 0;
moveable = false;
window.onresize = resizeEvent;
if (getBrowser()=="IE") msgObj.releaseCapture();
}
}
var closeBtn = tr.insertCell(-1);
closeBtn.style.cssText = "cursor:pointer; padding:2px;background-color:" + titlebgcolor+";";
closeBtn.innerHTML = "<span style='font-size:15pt; color:"+titlecolor+";'>×</span>";
closeBtn.onclick = function(){
document.body.removeChild(bgObj);
document.body.removeChild(msgObj);
document.body.removeChild(mask);
}
var msgBox = table.insertRow(-1).insertCell(-1);
msgBox.id = "MsgBox";
msgBox.style.cssText = "font:10pt '宋体';";
msgBox.colSpan = 2;
msgBox.innerHTML = msg;
}
// 获得事件Event对象，用于兼容IE和FireFox
function getEvent() {
return window.event || arguments.callee.caller.arguments[0];
}
// 事件绑定
function addEvent(obj,eventTypeName, fn){
if(obj.addEventListener){
obj.addEventListener(eventTypeName,fn,true);
return true;
}else if(obj.attachEvent){
return obj.attachEvent("on"+eventTypeName,fn);
}else{
return false;
}
}
// 检测浏览器类型
function getBrowser() {
var b;
if ((navigator.userAgent.indexOf("MSIE") >= 0) && (navigator.userAgent.indexOf('Opera') < 0)) {
b = "IE";
}else if (navigator.userAgent.indexOf("Firefox") >= 0) {
b = "Firefox";
}else if (navigator.userAgent.indexOf("Opera") >= 0){
b = "Opera";
}else {
b = "Other";
}
return b;
}



function setstyle(id, color) {
    var style = new Array();
    style['default'] = 'default';
    style['green'] = 'green';
    style['red'] = 'red';
    style['black'] = 'black';
	if(!cookie_namespace) cookie_namespace = '';
	if(!color) {
		setCookie(cookie_namespace+'style', id);
		$('#mainstyle').attr('href', 'img/'+id+'/style.css');
	}
	else {
		setCookie(cookie_namespace+'css', style[id]);
		$('#mainstyle').attr('href', 'img/default/'+style[id]+'.css');
	}
    //        alert(getCookie('style'));
	//    window.location.reload();
}

function getEditorText() {
    //            alert('loading...');
    if(!FCKeditor_OnComplete()) setTimeOut('getEditorText()', 100);
    var oEditor = FCKeditorAPI.GetInstance('content');
    $('#content').val(oEditor.GetXHTML());
    //            alert(oEditor.GetXHTML());
    return oEditor.GetXHTML();
}

function FCKeditor_OnComplete( editorInstance ) {
    return true;
}

$(function() {
    setInterval('lzwoa.common.autoScroll("#scrollDiv")',3000);
    $('#searchtype').change(function() {
        //            $('#search_article_form').attr('action', '');
        });
    $('#search_article_btn').submit(function(){
        //            $('#search_article_form').attr('action', '');
        })


});

var picPath;
var image;

// preview picture
function pview()
{
    //    alert(picPath);
    //    $('#box').html('图片载入中...').show();
    document.getElementById('preview').style.display = 'none';
    // 下面代码用来获得图片尺寸，这样才能在IE下正常显示图片
    //document.getElementById('box').innerHTML = "<img onload=\"DrawImage(this, 150);\" id='aPic' src='"+picPath+"'>";
    $('#box').html("<img onload=\"DrawImage(this, 150);\" id=\"aPic\" src=\""+picPath+"\">");
}

// show view button
function buttonShow()
{
    /*
这里用来解决图片加载延时造成的预览失败.
简单说明一下，当image对象的src属性发生改变时JavaScript会重新给image装载图片内容，
这通常是需要一些时间的，如果在加载完成之前想将图片显示出来就会造成错误，所以我们
通过图片的宽度和高度来判断图片是否已经被成功加载，加载完毕才会显示预览按钮.
这里我仍然有一个困惑，在IE7下预览效果偶尔会失效.
*/
    if ( image.width == 0 || image.height == 0 ) {
        setTimeout(buttonShow, 1000);
    } else {
        //        document.getElementById('preview').style.display = 'block';
        pview();
    }
}

function loadImage(ele) {
    picPath   = getPath(ele);
    image     = new Image();
    image.src = picPath.replace('\\', '/');
    setTimeout(buttonShow, 1000);
}

function getPath(obj)
{
    if(obj)
    {
        //ie
        if (window.navigator.userAgent.indexOf("MSIE")>=1)
        {
            obj.select();
            // IE下取得图片的本地路径
            return obj.value;
        //            alert(obj.value);
        //          return document.selection.createRange().text;
        }
        //firefox
        else if(window.navigator.userAgent.indexOf("Firefox")>=1)
        {
            if(obj.files)
            {
                // Firefox下取得的是图片的数据
                return obj.files.item(0).getAsDataURL();
            }
            return obj.value;
        }
        return obj.value;
    }
}

$.tabs = function(containerId, start) {
    var ON_CLASS = 'on';
    var id = '#'+ containerId;
    var i = (typeof start == "number") ? start - 1 : 0;
    $(id +'>div:eq(' +i+ ')').css({
        display:"block"
    });
    $(id +'>ul>li:nth-child(' +i+ ')').addClass(ON_CLASS);
    $(id +'>ul>li>a').click(function() {
        if (!$(this.parentNode).is('.'+ ON_CLASS)) {
            var re = /([_\-\w]+$)/i;
            var target = $('#'+ re.exec(this.href)[1]);
            if (target.size() > 0) {
                $(id +'>div:visible').css({
                    display:"none"
                });
                target.css({
                    display:"block"
                });
                $(id +'>ul>li').removeClass(ON_CLASS);
                $(this.parentNode).addClass(ON_CLASS);
            } else {
                alert('There is no such container.');
            }
        }
        return false;
    });
};
